package per.hx.bs.web.yw.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import per.hx.bs.base.BaseController;
import per.hx.bs.base.annotation.BsCLog;
import per.hx.bs.entity.yw.YwSignDO;
import per.hx.bs.util.PageUtils;
import per.hx.bs.util.Query;
import per.hx.bs.web.yw.service.YwSignService;

import java.util.List;
import java.util.Map;

/**
 * @author HuXing
 * @date 2018/4/20  0:10
 */
@Controller
@RequestMapping(value = "yw/sign")
public class SignController extends BaseController {
    private final String prefix = "yw/sign/";

    private final
    YwSignService signService;

    @Autowired
    public SignController(YwSignService signService) {
        this.signService = signService;
    }

    @BsCLog("进入签到管理界面")
    @RequiresPermissions("yw:sign:sign")
    @GetMapping(value = {"sign", "/"})
    public String sign() {
        return prefix + "sign";
    }

    @BsCLog("获取签到信息列表")
    @RequiresPermissions("yw:sign:sign")
    @GetMapping(value = "/sign/list")
    @ResponseBody
    public PageUtils list(@RequestParam Map<String, Object> params) {
        // 查询列表数据
        Query query = new Query(params);
        List<YwSignDO> sysUserList = signService.signList(query);
        int total = signService.signCount(query);
        return new PageUtils(sysUserList, total);
    }

}
